(0, require("../common/component").VantComponent)({
    relation: {
        name: "collapse-item",
        type: "descendant",
        linked: function(collapseItem) {
            this.children.push(collapseItem);
        },
        unlinked: function(collapseItem) {
            this.children = this.children.filter(function(child) {
                return child !== collapseItem;
            });
        }
    },
    props: {
        value: {
            type: null,
            observer: "updateExpanded"
        },
        accordion: {
            type: Boolean,
            observer: "updateExpanded"
        },
        border: {
            type: Boolean,
            value: !0
        }
    },
    beforeCreate: function() {
        this.children = [];
    },
    methods: {
        updateExpanded: function() {
            this.children.forEach(function(child) {
                child.updateExpanded();
            });
        },
        switch: function(itemName, expanded) {
            var data = this.data, isAccordion = data.accordion, currentValue = data.value;
            itemName = isAccordion ? expanded ? itemName : "" : expanded ? (currentValue || []).concat(itemName) : (currentValue || []).filter(function(name) {
                return name !== itemName;
            }), this.$emit("change", itemName), this.$emit("input", itemName);
        }
    }
});